package com.huika.dealontop.control.base.extend;

import com.huika.dealontop.config.UrlConstants;
import com.huika.dealontop.support.http.JSONWrapAjaxParams;

import java.lang.reflect.Type;

/**
 * Author: Victor Wu
 * Email: victor-wu*foxmail.com
 * Time: 2015/11/12 16:31
 * Description: 请求协议  封装url  和 请求参数JSONWrapAjaxParams
 */
public class RequestProtocol extends JSONWrapAjaxParams {
    private String mSubUrl;
    private String mHostUrl;

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    private Type type;

    public RequestProtocol() {
        this(null);
    }

    public RequestProtocol(String subUrl) {
        this(UrlConstants.ServerName, subUrl);
    }

    public RequestProtocol(String hostUrl, String subUrl) {
        this.mHostUrl = hostUrl;
        this.mSubUrl = subUrl;
    }

    /**
     * 获取URL后部分
     */
    public String getSubUrl() {
        return this.mSubUrl;
    }

    ;

    public void setSubUrl(String subUrl) {
        this.mSubUrl = subUrl;
    }

    public String getUrl() {
        return getHostUrl() + getSubUrl();
    }

    /**
     * 设置服务器根地址
     */
    protected void setHostUrl(String hostUrl) {
        this.mHostUrl = hostUrl;
    }

    /**
     * 获取服务器 根地址
     *
     * @return String
     */
    protected String getHostUrl() {
        return mHostUrl; //默认
    }

}
